home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / popupre / mdiparen.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-03-03  |  5.8 KB  |  150 lines

  1. VERSION 2.00
  2. Begin MDIForm frmMDIParent 
  3.    Caption         =   "MDI Parent"
  4.    ClientHeight    =   3660
  5.    ClientLeft      =   75
  6.    ClientTop       =   1905
  7.    ClientWidth     =   9405
  8.    Height          =   4065
  9.    Left            =   15
  10.    Top             =   1560
  11.    Width           =   9525
  12.    WindowState     =   2  'Maximized
  13.    Begin PictureBox picToolBar 
  14.       Align           =   1  'Align Top
  15.       BackColor       =   &H00E0E0E0&
  16.       BorderStyle     =   0  'None
  17.       FillColor       =   &H00808080&
  18.       ForeColor       =   &H00808080&
  19.       Height          =   3090
  20.       Left            =   0
  21.       ScaleHeight     =   3090
  22.       ScaleWidth      =   9405
  23.       TabIndex        =   0
  24.       Top             =   0
  25.       Width           =   9405
  26.       Begin Label Label3 
  27.          BackStyle       =   0  'Transparent
  28.          Caption         =   "2.   Close the MDI child window, press the MDI parent image button again and select the popup menu entry 'Show Modal Child Window'. A modal child window similar to the previously opened MDI child window comes up. But if you press its image button which should pop up the same menu as in the MDI child window, no popup menu appears. This happens because of the non-reentrancy of the code of the container window."
  29.          FontBold        =   0   'False
  30.          FontItalic      =   0   'False
  31.          FontName        =   "MS Sans Serif"
  32.          FontSize        =   8.25
  33.          FontStrikethru  =   0   'False
  34.          FontUnderline   =   0   'False
  35.          ForeColor       =   &H00FF0000&
  36.          Height          =   840
  37.          Left            =   585
  38.          TabIndex        =   4
  39.          Top             =   2130
  40.          Width           =   8205
  41.       End
  42.       Begin Label Label2 
  43.          BackStyle       =   0  'Transparent
  44.          Caption         =   "1.   Click on the 'Show MDI Child Window' entry of the popup menu. A MDI child window will open hat also contains an image button with a popup menu. This popup menu is also defined on the hidden container form. If you click on the image button, the popup menu appears. So far, so good."
  45.          FontBold        =   0   'False
  46.          FontItalic      =   0   'False
  47.          FontName        =   "MS Sans Serif"
  48.          FontSize        =   8.25
  49.          FontStrikethru  =   0   'False
  50.          FontUnderline   =   0   'False
  51.          ForeColor       =   &H00FF0000&
  52.          Height          =   675
  53.          Left            =   585
  54.          TabIndex        =   3
  55.          Top             =   1395
  56.          Width           =   8205
  57.       End
  58.       Begin Label Label1 
  59.          BackStyle       =   0  'Transparent
  60.          Caption         =   "The 'MouseDown' event of this image button pops up a menu that is defined on a hidden form (frmMenuContainer)."
  61.          FontBold        =   0   'False
  62.          FontItalic      =   0   'False
  63.          FontName        =   "MS Sans Serif"
  64.          FontSize        =   8.25
  65.          FontStrikethru  =   0   'False
  66.          FontUnderline   =   0   'False
  67.          ForeColor       =   &H00FF0000&
  68.          Height          =   360
  69.          Left            =   585
  70.          TabIndex        =   2
  71.          Top             =   1065
  72.          Width           =   8205
  73.       End
  74.       Begin Label lblMenuClick 
  75.          BackColor       =   &H000000FF&
  76.          ForeColor       =   &H000000FF&
  77.          Height          =   225
  78.          Left            =   8940
  79.          TabIndex        =   1
  80.          Top             =   810
  81.          Visible         =   0   'False
  82.          Width           =   285
  83.       End
  84.       Begin Image imgButtonUp 
  85.          Height          =   330
  86.          Left            =   8895
  87.          Picture         =   MDIPAREN.FRX:0000
  88.          Top             =   45
  89.          Visible         =   0   'False
  90.          Width           =   360
  91.       End
  92.       Begin Image imgButtonDown 
  93.          Height          =   330
  94.          Left            =   8895
  95.          Picture         =   MDIPAREN.FRX:0182
  96.          Top             =   390
  97.          Visible         =   0   'False
  98.          Width           =   360
  99.       End
  100.       Begin Image imgPopUp 
  101.          Height          =   330
  102.          Left            =   4380
  103.          Top             =   135
  104.          Width           =   360
  105.       End
  106.    End
  107. Option Explicit
  108. Sub HandleMyPopUp (P_nIndex As Integer)
  109. ' This sub handles the clicks on the menu entries of the
  110. ' MDI parent popup menu received by lblMenuClick from frmMenuContainer
  111.     Select Case P_nIndex
  112.     Case 0:
  113.         ' Show MDI child window
  114.         frmMDIChild.Show
  115.     Case 1:
  116.         ' Show modal child window
  117.         frmModalChild.Show 1
  118.     Case 3:
  119.         ' Exit
  120.         End
  121.     End Select
  122. End Sub
  123. Sub imgPopUp_MouseDown (Button As Integer, Shift As Integer, X As Single, Y As Single)
  124.     ' Show 'button down' image
  125.     imgPopUp = imgButtonDown
  126.     ' Pop up the MDI parent menu defined in frmMenuContainer
  127.     PopupMenu frmMenuContainer.mnuPopUpMDIParent, 0
  128.     ' Show 'button up' image
  129.     imgPopUp = imgButtonUp
  130. End Sub
  131. Sub lblMenuClick_Change ()
  132. ' The 'Change' event of this label is triggered when a click on
  133. ' a menu entry in frmMenuContainer sets the label caption with the
  134. ' related menu entry index
  135.     ' Handle the menu click if an index is available
  136.     If lblMenuClick <> "" Then HandleMyPopUp Val(lblMenuClick)
  137.     ' Reset the label for new menu entry clicks
  138.     lblMenuClick = ""
  139. End Sub
  140. Sub MDIForm_Load ()
  141.     ' Startup: Load the hidden menu container form
  142.     Load frmMenuContainer
  143.     ' Show 'button up' image initially
  144.     imgPopUp = imgButtonUp
  145. End Sub
  146. Sub MDIForm_QueryUnload (Cancel As Integer, UnloadMode As Integer)
  147.     ' Ends the app when the system menu is used
  148.     End
  149. End Sub
  150.